package com.yeping.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yeping.domain.ResponseResult;
import com.yeping.domain.entity.Article;
import com.yeping.domain.entity.Book;
import com.yeping.mapper.BookMapper;
import com.yeping.service.BookService;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.yeping.constants.SystemConstants.ARTICLE_STATUS_NORMAL;

/**
 * (Book)表服务实现类
 *
 * @author makejava
 * @since 2024-04-02 15:07:41
 */
@Service("bookService")
public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
    @Override
    public ResponseResult bookAll() {
        LambdaQueryWrapper<Book> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(Book::getDelFlag, ARTICLE_STATUS_NORMAL);
        List<Book> books = list(queryWrapper);
        return ResponseResult.okResult(books);
    }

    @Override
    public ResponseResult bookSearch(String keyWord) {
        List<Book> books = getBaseMapper().search(keyWord);
        return ResponseResult.okResult(books);
    }
}
